<template>
  <div>
    <!--页面-->
    <el-card>
      <!--搜索框-->
      <div style="margin-bottom: 15px">
        <el-input placeholder="请输入内容" v-model="query" class="input-with-select">
          <el-button slot="append" icon="el-icon-search" @click="getlist()"></el-button>
        </el-input>
      </div>
      <!--表格区域-->
      <el-table :data="tableData" stripe style="width: 100%" border>
        <el-table-column label="#" width="80" type="index"> </el-table-column>
        <el-table-column prop="order_number" label="订单编号"> </el-table-column>
        <el-table-column prop="order_price" label="订单价格"> </el-table-column>
        <el-table-column prop="pay_status" label="是否付款">
          <template slot-scope="scope">
            <el-tag v-show="scope.row.pay_status == '0'" type="danger">未付款</el-tag>
            <el-tag type="success" v-show="scope.row.pay_status == '1'">已付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货"> </el-table-column>
        <el-table-column prop="create_time" label="下单时间">
          <template slot-scope="scope">
            {{ scope.row.create_time | time }}
          </template>
        </el-table-column>
        <el-table-column prop="address" label="操作">
          <template slot-scope="scope">
            <el-button
              type="primary"
              icon="el-icon-edit"
              circle
              @click="ask(scope.row)"
            ></el-button>
            <el-button
              type="success"
              icon="el-icon-location-information"
              circle
              @click="getogistics()"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>
      <!--分页-->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pagenum"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-card>
    <!--修改地址-->
    <el-dialog title="修改地址" :visible.sync="flag">
      <el-form :model="form" :rules="rules" ref="form">
        <el-form-item label="省市区/县" label-width="100px" prop="address">
          <div class="block">
            <el-cascader
              v-model="value"
              :options="options"
              @change="handleChange"
            ></el-cascader>
          </div>
        </el-form-item>
        <el-form-item label="详细地址" label-width="100px" prop="addresses">
          <el-input v-model="form.addresses" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="flag = false">取 消</el-button>
        <el-button type="primary" @click="flag = false">确 定</el-button>
      </div>
    </el-dialog>
    <!--物流信息-->
    <el-dialog title="物流进度" :visible.sync="sflag">
      <div>
        <el-steps direction="vertical" :active="1" finish-status="success">
          <el-step
            v-for="(item, index) in List"
            :key="index"
            :title="item.context"
            :description="item.ftime"
          ></el-step>
        </el-steps>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="sflag = false">取 消</el-button>
        <el-button type="primary" @click="sflag = false">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      tableData: [],
      logistics: [],
      List: [],

      query: "",
      pagenum: 1,
      pagesize: 5,

      total: 0,
      //弹框
      flag: false,
      sflag: false,
      form: {
        address: "",
        addresses: "",
      },
      rules: {
        address: [{ required: true, message: "请输入省市县", trigger: "blur" }],
        addresses: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
      },
      value: [],
      options: [
        {
          value: "hebei",
          label: "河北",
          children: [
            {
              value: "shijiazhuang",
              label: "石家庄",
              children: [
                {
                  value: "changanqu",
                  label: "长安区",
                },
                {
                  value: "yuhuaqu",
                  label: "裕华区",
                },
                {
                  value: "jingxingxian",
                  label: "井陉县",
                },
                {
                  value: "luquanshi",
                  label: "鹿泉市",
                },
              ],
            },
          ],
        },
      ],
    };
  },
  mounted() {
    this.getlist();
  },
  methods: {
    //请求数据
    async getlist() {
      let { data: res } = await this.$http.get(
        `orders?query=${this.query}&pagenum=${this.pagenum}&pagesize=${this.pagesize}`
      );
      console.log(res);
      this.tableData = res.data.goods; //赋值
      this.total = res.data.total; //总条数
    },
    //请求物流信息
    async getogistics() {
      let { data: res } = await this.$http.get(`/kuaidi/804909574412544580`);
      console.log(res);
      this.List = res.data;
      this.sflag = true;
    },
    ask() {
      this.flag = true;
    },

    //分页
    handleSizeChange(size) {
      this.pagesize = size;
      this.getlist();
    },
    handleCurrentChange(page) {
      this.pagenum = page;
      this.getlist();
    },
    //联动导航
    handleChange(value) {
      console.log(value);
    },
    // 物流信息
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then(() => {
          done();
        })
        .catch(() => {});
    },
  },
  computed: {},
  watch: {},
};
</script>

<style lang="scss" scoped>
.el-input {
  width: 28%;
}
.el-table {
  margin-bottom: 15px;
}
.el-dialog {
  .el-input {
    width: 95%;
  }
  .el-cascader {
    width: 95%;
  }
}
</style>
